package com.dsp.soundscape.server;

import java.io.File;

import org.springframework.beans.factory.annotation.Autowired;

import com.dsp.soundscape.model.AlbumInfo;

public abstract class AbstractScanner {
	protected ConfigManager configuration;

	@Autowired
	public void setConfiguration(ConfigManager configuration) {
		this.configuration = configuration;
	}

	public void scan(AlbumInfo info) {
		File parentDir = new File (configuration.getPathroot() + "/" + info.getFullpath());

		if (parentDir != null) {
			File[] files = parentDir.listFiles();
			if (files != null) {
				fileHandler(info, files, parentDir);
			}
		}
		
		info.setPopulated(true);
	}
	
	protected abstract void fileHandler(AlbumInfo info, File[] files, File parentDir);
}
